from django_filters import rest_framework as filters
from .models import DataRecord, Table, TableFields


class DataRecordFilter(filters.FilterSet):
    table = filters.ModelChoiceFilter(required=True, queryset=Table.objects.all(), label='所属表')

    class Meta:
        model = DataRecord
        fields = ['table', 'row_num']


class TableFieldsFilter(filters.FilterSet):
    table = filters.ModelChoiceFilter(queryset=Table.objects.all(), label='所属表')

    class Meta:
        model = TableFields
        fields = ['table']
